<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <link rel="stylesheet" th:href="@{/css/bootstrap-5.3.0-alpha1-dist/css/bootstrap.min.css}">
    <script th:src="@{/js/jquery-3.5.1.js}"></script>
    <script th:src="@{/js/bootstrap4.1.3.main.js}"></script>
    <script th:src="@{/js/bootstrap.bundle.js}"></script>
    <link th:href="@{/css/Count.css}" rel="stylesheet">
</head>
<body>
<div class="container">
    <table class="table-bordered" th:object="${Result?.data}">
        <thead><h3>账号剩余停车次数</h3></thead>
        <tbody>
        <tr class="table-active ">
            <th>账号</th>
            <th colspan="3">车牌号</th>
            <th th:if="${Result.data.usertype eq '次卡'}"  >
                <a class="nav-link" data-src="/users/usercheckcount">剩余次数</a>
            </th>
            <th th:if="${Result.data.usertype eq '月卡'}">
                <a class="nav-link" data-src="/users/usercheckcount">剩余时长</a>
            </th>
        </tr>
        <tr>
            <td th:text="*{tel}"></td>
            <td th:text="*{code1}"></td>
            <td th:text="*{code2}"></td>
            <td th:text="*{code3}"></td>
            <td id="cika"   th:if="${Result.data.usertype eq '次卡'}"></td>
            <td id="yueka"  th:if="${Result.data.usertype eq '月卡'}"></td>

        </tr>
        </tbody>
         <input  id="money" hidden="hidden" th:value="*{money}">
        <input  id="usertype" hidden="hidden" th:value="*{usertype}">
    </table>
</div>

<script>
    window.onload = function() {
        var money = document.getElementById("money");
        var usertype = document.getElementById("usertype");
        var cika = document.getElementById("cika");
        var yueka = document.getElementById("yueka");
        if(usertype.value==='次卡') {
            if (parseInt(money.value) / 50 < 0) {
                cika.textContent = parseInt(money.value) / 50;
            } else {
                cika.textContent = parseInt(parseInt(money.value) / 50)*4 +parseInt((parseInt(money.value) % 50) / 15);
            }
        }
else {
            if (parseInt(money.value) / 50 < 0) {
                yueka.textContent = money.value;
            } else {
                yueka.textContent = (parseInt(parseInt(money.value) / 50))*55 + parseInt(money.value)%50;
            }
        }
    }
</script>
</body>
</html>